// import { NextResponse } from "next/server";
// import type { NextRequest } from "next/server";
// import { isAuthenticated } from "./lib/auth";

// const legacyPrefixes = ["/api/user", "/blog"];
// export async function middleware(request: NextRequest) {
//   const { pathname } = request.nextUrl;

//   if (pathname.startsWith("/admin")) {
//     const flag = await isAuthenticated(request);
//     if (!flag) {
//       return NextResponse.redirect(new URL("/login", request.url));
//     }
//     // const user: any = flag.jwtData;
//     // request.cookies.set('userId', user.id)
//   }

//   return NextResponse.next();
// }

// See "Matching Paths" below to learn more

import { composeMiddleware } from "@/middlewares/util/chain";
import { middlewares } from "./middlewares";

export default composeMiddleware(middlewares);

export const config = {
  matcher: "/admin/:path*",
};
// export const config = {
//   // 匹配所有不以 _next/static、_next/image 或 favicon.ico 开头的字符串 '/api/:path*'
//   matcher: ['/((?!_next/static|_next/image|favicon.ico).*)'],
// }
